package supuestaVista_jsp;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.List;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JSeparator;
import javax.swing.JTextField;

import javax.swing.WindowConstants;
import javax.swing.SwingUtilities;

import app.Odv;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class SolicitudCotizacion extends javax.swing.JFrame {
	private JTextField jTextFieldMarca;
	private JSeparator jSeparator1;
	private JTextField jTextField1;
	private JLabel jLabel3;
	private JTextField jTextFieldCuil;
	private JButton jButtonFinalizar;
	private JLabel jLabelorigen;
	private JLabel jLabel2;
	private JTextField jTextFieldCantidad;
	private JLabel jLabel1;
	private JButton jButtonAgregar;
	private JTextField jTextFieldnorig;
	private JLabel jLabelmarca;
	private JTextField jTextFieldCodigo;
	private JLabel jLabelCodigo;
	private JTextField jTextFieldSerie;
	private JLabel jLabelserie;
	

	/**
	* Auto-generated main method to display this JFrame
	*/
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				SolicitudCotizacion inst = new SolicitudCotizacion();
				inst.setLocationRelativeTo(null);
				inst.setVisible(true);
			}
		});
	}
	
	public SolicitudCotizacion() {
		super();
		initGUI();
	}
	
	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			getContentPane().setLayout(null);
			{
				jLabelserie = new JLabel();
				getContentPane().add(jLabelserie);
				jLabelserie.setText("serie");
				jLabelserie.setBounds(12, 142, 45, 16);
			}
			{
				jTextFieldSerie = new JTextField();
				getContentPane().add(jTextFieldSerie);
				jTextFieldSerie.setBounds(92, 139, 87, 23);
			}
			{
				jLabelCodigo = new JLabel();
				getContentPane().add(jLabelCodigo);
				jLabelCodigo.setText("codigo");
				jLabelCodigo.setBounds(12, 193, 52, 16);
			}
			{
				jTextFieldCodigo = new JTextField();
				getContentPane().add(jTextFieldCodigo);
				jTextFieldCodigo.setBounds(92, 190, 92, 23);
			}
			{
				jLabelmarca = new JLabel();
				getContentPane().add(jLabelmarca);
				jLabelmarca.setText("marca");
				jLabelmarca.setBounds(12, 235, 52, 16);
			}
			{
				jTextFieldMarca = new JTextField();
				getContentPane().add(jTextFieldMarca);
				jTextFieldMarca.setBounds(92, 232, 92, 23);
			}
			{
				jLabelorigen = new JLabel();
				getContentPane().add(jLabelorigen);
				jLabelorigen.setText("origen");
				jLabelorigen.setBounds(12, 279, 52, 16);
			}
			{
				jTextFieldnorig = new JTextField();
				getContentPane().add(jTextFieldnorig);
				jTextFieldnorig.setBounds(92, 276, 92, 23);
			}
			{
				jButtonAgregar = new JButton();
				getContentPane().add(jButtonAgregar);
				jButtonAgregar.setText("AGREGAR");
				jButtonAgregar.setBounds(80, 378, 66, 23);
				jButtonAgregar.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt) {
						System.out.println("jButtonAgregar.actionPerformed, event="+evt);
						
						Odv s= Odv.getinstancia();
						
						
						
						
						if(s.esClienteValido(jTextField1.getText())==true){
							
							if(s.coincideIdRz(jTextField1.getText(), jTextFieldCuil.getText())){
								
								System.out.println("pasa la parte del cliente");
								
							
							if(s.existeNs(jTextFieldSerie.getText())==true){
								
								Odv.getinstancia().generarListaDeItems(jTextFieldSerie.getText(), jTextFieldCodigo.getText(), jTextFieldMarca.getText(),
										jTextFieldnorig.getText(),Integer.parseInt(jTextFieldCantidad.getText()) );
								
								Agregar v= new Agregar();
								v.setVisible(true);
								v.setLocationRelativeTo(null);
								
								jTextFieldCantidad.setText("");
								jTextFieldCodigo.setText("");
								jTextFieldMarca.setText("");
								jTextFieldnorig.setText("");
								jTextFieldSerie.setText("");							
								
							}
							else{
								System.out.println("no existe numero de serie");
								return;
							}
								
								
							}
							else{
								NoCoincide v1= new NoCoincide();
								v1.setVisible(true);
							}
						}
						
						else{
							CuilNoValido v2=new CuilNoValido();
							v2.setVisible(true);
						}
						
						
						
						
						
					}
				});
			}
			{
				jButtonFinalizar = new JButton();
				getContentPane().add(jButtonFinalizar);
				jButtonFinalizar.setText("Finalizar");
				jButtonFinalizar.setBounds(211, 376, 61, 28);
				jButtonFinalizar.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt) {
						System.out.println("jButtonFinalizar.actionPerformed, event="+evt);
						
						Odv s= Odv.getinstancia();
						// TODO
						//s.generarListaDeSolicitudes(jTextField1.getText());
						
						dispose();
						
					}
				});
			}
			{
				jLabel1 = new JLabel();
				getContentPane().add(jLabel1);
				jLabel1.setText("cantidad: ");
				jLabel1.setBounds(12, 329, 52, 16);
			}
			{
				jTextFieldCantidad = new JTextField();
				getContentPane().add(jTextFieldCantidad);
				jTextFieldCantidad.setBounds(92, 326, 80, 24);
			}
			{
				jLabel2 = new JLabel();
				getContentPane().add(jLabel2);
				jLabel2.setText("Cuil:");
				jLabel2.setBounds(20, 26, 60, 40);
			}
			{
				jTextFieldCuil = new JTextField();
				getContentPane().add(jTextFieldCuil);
				jTextFieldCuil.setBounds(114, 87, 87, 24);
			}
			{
				jLabel3 = new JLabel();
				getContentPane().add(jLabel3);
				jLabel3.setText("RazonSocial:");
				jLabel3.setBounds(12, 78, 90, 40);
			}
			{
				jTextField1 = new JTextField();
				getContentPane().add(jTextField1);
				jTextField1.setBounds(104, 35, 92, 21);
			}
			{
				jSeparator1 = new JSeparator();
				getContentPane().add(jSeparator1);
				jSeparator1.setBounds(0, 118, 384, 10);
			}
			pack();
			this.setSize(400, 459);
		} catch (Exception e) {
		    //add your error handling code here
			e.printStackTrace();
		}
	}

}
